#include "authcodeinfobean.h"

AuthCodeInfoBean::AuthCodeInfoBean()
{

}

void AuthCodeInfoBean::jsonToObject(QByteArray jsonArrayStr, AuthCodeInfoBean &authCodeInfoBean)
{
    QJsonParseError jsonError;
    const QJsonDocument &document = QJsonDocument::fromJson(jsonArrayStr, &jsonError);
    if(document.isNull() || jsonError.error != QJsonParseError::NoError) return;
    if(!document.isObject()) return;
    QJsonObject obj = document.object();
    if(!obj.isEmpty()){
        if(obj.contains("message")){
            authCodeInfoBean.message = obj.value("message").toString();
        }

        if(obj.contains("code")){

            authCodeInfoBean.code = obj.value("code").toInt();
        }

        if(obj.contains("data")){
            QJsonObject dataObj = obj.value("data").toObject();
            if(dataObj.contains("invalidTime")){
                authCodeInfoBean.data.invalidTime = QString::number(dataObj.value("invalidTime").toDouble(), 'f', 0).toLongLong();
            }

        }
    }
}
